package com.xayy.health.mgt.service.strategy;

import com.xayy.health.mgt.model.vo.HealthAssessParam;
import com.xayy.health.mgt.service.strategy.health.AnalyticHierarchyStrategy;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Nie
 * @version V1.0
 * @date 2023/4/10 11:05
 */
public enum HealthAlgorithmEnum {
    //AHP
    COMPREHENSIVE_EVALUATION(1, "AHP", AnalyticHierarchyStrategy.builder().build()),
    ;

    @Getter
    private int code;
    @Getter
    private String msg;
    @Getter
    private AlgorithmStrategy<HealthAssessParam> algorithm;

    HealthAlgorithmEnum(int code, String msg, AlgorithmStrategy<HealthAssessParam> algorithm) {
        this.code = code;
        this.msg = msg;
        this.algorithm = algorithm;
    }

    public static AlgorithmStrategy<HealthAssessParam> mathAlgorithm(int code) {
        HealthAlgorithmEnum[] values = HealthAlgorithmEnum.values();
        for (HealthAlgorithmEnum value : values) {
            if (value.getCode() == code) {
                return value.getAlgorithm();
            }
        }
        return null;
    }

    public static List<Map<String, Object>> list() {
        HealthAlgorithmEnum[] values = HealthAlgorithmEnum.values();
        List<Map<String, Object>> list = new ArrayList<>(0);
        for (HealthAlgorithmEnum value : values) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", value.getCode());
            map.put("msg", value.getMsg());
            list.add(map);
        }
        return list;
    }
}
